package cn.tedu.Bi.service

import cn.tedu.Bi.mapper.BiMapper
import org.springframework.beans.factory.annotation.Autowired
import java.text.SimpleDateFormat
import javax.servlet.http.HttpServletResponse
import org.springframework.stereotype.Service
@Service
class BiService() {

  @Autowired
  private var biMapper: BiMapper = _

  def BiView(res: HttpServletResponse) {
    val timeStamp = System.currentTimeMillis()
    val ttime = new SimpleDateFormat("YYYY-MM-dd").format(timeStamp)
    val xtime = new SimpleDateFormat("HH-mm-ss").format(timeStamp)
    val result = biMapper.queryAll(ttime).map(_.setXtime(xtime))
    if (result != null)
      result.foreach(a => res.getWriter.write(a.toString))
    else
      res.getWriter.write("['" + xtime + "',0,0,0,0,0]")
  }
}